home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / elm / elm2.4 / src / a_screen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-15  |  6.3 KB  |  204 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: a_screen.c,v 5.4 1993/04/16 03:53:43 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.4 $   $State: Exp $
  6.  *
  7.  *             Copyright (c) 1988-1992 USENET Community Trust
  8.  *             Copyright (c) 1986,1987 Dave Taylor
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log: a_screen.c,v $
  17.  * Revision 5.4  1993/04/16  03:53:43  syd
  18.  * fix wrong softkeys displayed
  19.  * From: From: Michael Greenberg <hp.com!hpbbn.bbn.hp.com!hputlaa!hputlav!michael>
  20.  *
  21.  * Revision 5.3  1993/01/19  04:52:19  syd
  22.  *     add c)hange alias command to alias helpfile
  23.  *     if a deleted alias is changed, undelete it.  Also added the 'N'
  24.  * flag to changed aliases to help remind the user.  Documented it.
  25.  * Note:  if they mark the alias for deletion AFTER making the change it
  26.  * WILL be deleted. (and marked accordingly)
  27.  *     modified alias mode title string to indicate when a resync was
  28.  * needed.
  29.  *     allow editing alias file when none exist.
  30.  *     Now aliases are check for illegal characters (and WS) and
  31.  * addresses are check for illegal WS when they are being entered.  If
  32.  * anything illegal is found and message is printed and they keep entering
  33.  * the item until they get it right.
  34.  *     I fixed a couple of places where int should be long to match
  35.  * the declared type of alias_rec.length
  36.  * From: "Robert L. Howard" <robert.howard@matd.gatech.edu>
  37.  *
  38.  * Revision 5.2  1992/12/20  05:15:58  syd
  39.  * Add a c)hange alias, -u and -t options to listalias to list only user
  40.  * and only system aliases respectively.
  41.  * From: "Robert L. Howard" <robert.howard@matd.gatech.edu>
  42.  *
  43.  * Revision 5.1  1992/10/03  22:58:40  syd
  44.  * Initial checkin as of 2.4 Release at PL0
  45.  *
  46.  *
  47.  ******************************************************************************/
  48.  
  49. /**  alias screen display routines for ELM program
  50.  
  51. **/
  52.  
  53. #include "headers.h"
  54. #include "s_aliases.h"
  55.  
  56. char *show_status();
  57. char *alias_type();
  58.  
  59. alias_screen(modified)
  60. int modified;
  61. {
  62.     /* Stolen from showscreen() */
  63.  
  64.     ClearScreen();
  65.  
  66.     alias_title(modified);
  67.  
  68.     last_header_page = -1;         /* force a redraw regardless */
  69.     show_headers();
  70.  
  71.     if (mini_menu)
  72.       show_alias_menu();
  73.  
  74.     show_last_error();
  75.  
  76.     if (hp_terminal)
  77.       define_softkeys(ALIAS);
  78. }
  79.  
  80. alias_title(modified)
  81. int modified;
  82. {
  83.     /** display a new title line, due to re-sync'ing the aliases **/
  84.     /* Stolen from update_title() */
  85.  
  86.     char buffer[SLEN];
  87.     char modmsg[SLEN];
  88.  
  89.     if (modified) {
  90.         strcpy(modmsg, catgets(elm_msg_cat, AliasesSet, AliasesModified,
  91.         "(modified, resync needed) "));
  92.     }
  93.     else {
  94.         modmsg[0] = '\0';
  95.     }
  96.  
  97.     if (selected)
  98.       MCsprintf(buffer, catgets(elm_msg_cat, AliasesSet, AliasesSelect,
  99.           "Alias mode: %d shown out of %d %s[ELM %s]"),
  100.           selected, message_count, modmsg, version_buff);
  101.     else if (message_count == 1)
  102.       sprintf(buffer, catgets(elm_msg_cat, AliasesSet, AliasesSingle,
  103.           "Alias mode: 1 alias %s[ELM %s]"), modmsg, version_buff);
  104.     else
  105.       MCsprintf(buffer, catgets(elm_msg_cat, AliasesSet, AliasesPlural,
  106.           "Alias mode: %d aliases %s[ELM %s]"),
  107.           message_count, modmsg, version_buff);
  108.  
  109.     ClearLine(1);
  110.  
  111.     Centerline(1, buffer);
  112. }
  113.  
  114. show_alias_menu()
  115. {
  116.     /** write alias menu... **/
  117.     /* Moved from alias.c */
  118.  
  119.     if (user_level == RANK_AMATEUR) {    /* Give less options  */
  120.       Centerline(LINES-7, catgets(elm_msg_cat, AliasesSet, AliasesRMenuLn1,
  121. "You can use any of the following commands by pressing the first character;"));
  122.       Centerline(LINES-6, catgets(elm_msg_cat, AliasesSet, AliasesRMenuLn2,
  123. "a)lias current message, n)ew alias, d)elete or u)ndelete an alias,"));
  124.       Centerline(LINES-5, catgets(elm_msg_cat, AliasesSet, AliasesRMenuLn3,
  125. "m)ail to alias, or r)eturn to main menu.  To view an alias, press <return>."));
  126.       Centerline(LINES-4, catgets(elm_msg_cat, AliasesSet, AliasesRMenuLn4,
  127. "j = move down, k = move up, ? = help"));
  128.     }
  129.     else {
  130.         Centerline(LINES-7, catgets(elm_msg_cat, AliasesSet, AliasesMenuLn1,
  131. "Alias commands:  ?=help, <n>=set current to n, /=search pattern"));
  132.         Centerline(LINES-6, catgets(elm_msg_cat, AliasesSet, AliasesMenuLn2,
  133. "a)lias current message, c)hange, d)elete, e)dit aliases.text, f)ully expand,"));
  134.         Centerline(LINES-5, catgets(elm_msg_cat, AliasesSet, AliasesMenuLn3,
  135. "l)imit display, m)ail, n)ew alias, r)eturn, t)ag, u)ndelete, or e(x)it"));
  136.     }
  137.  
  138. }
  139.  
  140. build_alias_line(buffer, entry, message_number, highlight)
  141. char *buffer;
  142. struct alias_rec *entry;
  143. int message_number, highlight;
  144. {
  145.     /** Build in buffer the alias header ... entry is the current
  146.         message entry, 'highlight' is either TRUE or FALSE,
  147.         and 'message_number' is the number of the message.
  148.     **/
  149.  
  150.     char mybuffer[SLEN];
  151.  
  152.     /** Note: using 'strncpy' allows us to output as much of the
  153.         subject line as possible given the dimensions of the screen.
  154.         The key is that 'strncpy' returns a 'char *' to the string
  155.         that it is handing to the dummy variable!  Neat, eh? **/
  156.     /* Stolen from build_header_line() */
  157.  
  158.     int name_width;
  159.  
  160.     /* Note that one huge sprintf() is too hard for some compilers. */
  161.  
  162.     sprintf(buffer, "%s%s%c%-3d ",
  163.         (highlight && arrow_cursor)? "->" : "  ",
  164.         show_status(entry->status),
  165.         (entry->status & TAGGED?  '+' : ' '),
  166.         message_number);
  167.  
  168.     /* Set the name display width. */
  169.     name_width = COLUMNS-40;
  170.  
  171.     /* Put the name and associated comment in local buffer */
  172.     if (strlen(entry->comment))
  173.       MCsprintf(mybuffer, "%s, %s", entry->name, entry->comment);
  174.     else
  175.       sprintf(mybuffer, "%s", entry->name);
  176.  
  177.     /* complete line with name, type and alias. */
  178.     sprintf(buffer + strlen(buffer), "%-*.*s %s %-18.18s",
  179.         /* give max and min width parameters for 'name' */
  180.         name_width, name_width, mybuffer,
  181.         alias_type(entry->type),
  182.         entry->alias);
  183. }
  184.  
  185. char *alias_type(type)
  186. int type;
  187. {
  188.     /** This routine returns a string showing the alias type,
  189.         'Person' or 'Group' aliases.  Additionally, a '(S)'
  190.         is appended if this is a system alias.
  191.     **/
  192.  
  193.     static char mybuffer[10];
  194.     extern char *a_group_name, *a_person_name, *a_system_flag;
  195.  
  196.     if (type & GROUP)    strcpy(mybuffer, a_group_name);
  197.     else            strcpy(mybuffer, a_person_name);
  198.  
  199.     if (type & SYSTEM)    strcat(mybuffer, a_system_flag);
  200.     else            strcat(mybuffer, "   ");
  201.  
  202.     return( (char *) mybuffer);
  203. }
  204.